package testing;

import gamemngr.GameMngr;
import junit.framework.TestCase;
import logic.Country;
import logic.Player;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;

public class CountryTest extends TestCase {
	public CountryTest(String name) {
		super(name);
	}
	@Before
	public void setUp() throws Exception {
		super.setUp();
	}

	@After
	public void tearDown() throws Exception {
		super.tearDown();
	}

	@Test
	public void testCountry() {
		Country c = new Country("Kaka");
		assertEquals("Kaka", c.toString());
	}

	@Test
	public void testAddNeighbor() {
		Country c = new Country("Kaka");
		Country nc= new Country("Makaka");
		c.addNeighbor(nc);
		assertEquals(nc, c.getNeighbors().get("Makaka"));
	}

	@Test
	public void testGetName() {
		Country c = new Country("Kaka");
		assertEquals("Kaka", c.toString());
	}

	@Test
	public void testEqualsObject() {
		Country c = new Country("Kaka");
		Country d = new Country("Kaka");
		Country e = new Country("Makaka");
		
		assertEquals(true, c.equals(d));
		assertEquals(false, c.equals(e));
	}

	@Test
	public void testHasOwner() {
		Country c = new Country("Kaka");
		Player p = new Player("Eugene",new GameMngr());
		assertEquals(false, c.hasOwner());
		p.addCountry(c);
		assertEquals(true, c.hasOwner());
	}

	@Test
	public void testGetOwner() {
		Country c = new Country("Kaka");
		Player p = new Player("Eugene",new GameMngr());
		assertEquals(null, c.getOwner());
		p.addCountry(c);
		assertEquals(p, c.getOwner());
	}

	@Test
	public void testSetOwner() {
		Country c = new Country("Kaka");
		Player p = new Player("Eugene",new GameMngr());
		p.addCountry(c);
		assertEquals(p, c.getOwner());
	}

	@Test
	public void testGetNeighbors() {
		Country c = new Country("Kaka");
		Country d = new Country("Makaka");
		Country e = new Country("Alabama");
		assertEquals(0, c.getNeighbors().entrySet().size());
		c.addNeighbor(d);
		assertEquals(1, c.getNeighbors().entrySet().size());
		c.addNeighbor(e);
		assertEquals(2, c.getNeighbors().entrySet().size());
	}

}
